#ifndef SINGLETON_H_
#define SINGLETON_H_

#include "main.h"


template <class U>
class Singleton{

private :

	static U* instance;

protected:

	  // Constructeur/destructeur
	  Singleton () {std::cout << "creating singleton." << std::endl; }
	  ~Singleton () { std::cout << "destroying singleton." << std::endl; }

public:

	static U* getInstance(){
		if(instance == nullptr)
			instance = new U();
		return instance;
	}

	static bool isAlive(){
		return (instance != nullptr);
	}

	static void kill(){
		if(isAlive()){
			delete instance;
			instance = nullptr;
		}
	}

};

template <class U>
U* Singleton<U>::instance = nullptr;


#endif // SINGLETON_H_
